package com.gs.spring.core.simple;

import java.util.Date;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

import com.gs.spring.core.util.Timestamp;

public class SuperSimpleBean implements InitializingBean
										, DisposableBean
										{
	public SuperSimpleBean() {
		creationDate = new Date();
		System.out.println("____________________");
		System.out.println("Creating bean using default contructor");
		System.out.println("____________________");
	}
	String name;
	public SuperSimpleBean(String name) {
		creationDate = new Date();
		System.out.println("__________________________________________________");
		System.out.println("Creating bean with single argument constructor...");
		System.out.println("__________________________________________________");
		this.name = name;
	}
	
	private SimpleRequestBean simpleRequestBean;
	public SimpleRequestBean getSimpleRequestBean() {
		return simpleRequestBean;
	}
	public void setSimpleRequestBean(SimpleRequestBean simpleRequestBean) {
		this.simpleRequestBean = simpleRequestBean;
	}
	
	private SimpleSessionBean simpleSessionBean;
	public SimpleSessionBean getSimpleSessionBean() {
		return simpleSessionBean;
	}
	public void setSimpleSessionBean(SimpleSessionBean simpleSessionBean) {
		this.simpleSessionBean = simpleSessionBean;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Timestamp
	Date creationDate;
	
	@PostConstruct
	public void initialize(){
		System.out.println("@PostContruct Initializing bean " + getClass());
	}
	
	@PreDestroy
	public void cleanUp(){
		System.out.println("Cleaning up bean " + getClass());
	}
	
	@Override
	public String toString() {
		return "Bean was created at " + this.creationDate;
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("Further initializing in afterPropertiesSet() bean " + getClass());		
	}

	@Override
	public void destroy() throws Exception {
		System.out.println("Further cleanUp in destroy() bean " + getClass());
	}
}
